package com.example.templateapp.ui.adapter

import android.view.View
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.example.templateapp.R

import com.example.templateapp.ui.adapter.base.SimpleDelegateAdapter
import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder

class SelectedAdapter :
    SimpleDelegateAdapter<String>(R.layout.adapter_select_item, LinearLayoutHelper()) {

    val selectIdxs = mutableSetOf<Int>()

    override fun bindData(holder: RecyclerViewHolder, position: Int, item: String) {


        holder.text(R.id.select_tv, item)
        holder.itemView.setOnClickListener {
            if (holder.getView(R.id.select_check).visibility == View.VISIBLE) {
                holder.visible(R.id.select_check, View.INVISIBLE)
                selectIdxs.remove(position)
            } else {
                holder.visible(R.id.select_check, View.VISIBLE)
                selectIdxs.add(position)
            }
        }
    }
}